package br.com.andre.neo4j.model;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;

public class Connection {
	private static final String path = "/home/andre/Documentos/locadoraDB";

	public GraphDatabaseService newConnection() {
		GraphDatabaseService graph = new GraphDatabaseFactory().newEmbeddedDatabase(path);
		registerShutdownHook(graph);
		return graph;
	}
	private void registerShutdownHook(final GraphDatabaseService graph) {
		Runtime.getRuntime().addShutdownHook(new Thread(){
			@Override
			public void run() {
				graph.shutdown();
			}
		});
		
	}
}
